package com.atguigu01.create.ex1;
/*
* 练习:创建两个分线程，其中一个线程遍历100以内的偶数，另一个线程遍历100以内的奇数。

 * */
public class EvenandOdd {
    public static void main(String[] args) {
        Even e1=new Even();
        Odd o1=new Odd();
        e1.start();
        o1.start();
        //方式2
        new Even(){
            public void run() {
                for (int i = 0; i <=100; i++) {
                    if(i%2==0){
                        System.out.println("even "+i);
                    }
                }
            }
        }.start();

    }
}

class Even extends Thread{
    @Override
    public void run() {
        for (int i = 0; i <=100; i++) {
            if(i%2==0){
                System.out.println("even "+i);
            }
        }
    }
}

class Odd extends Thread{
    @Override
    public void run() {
        for (int i = 0; i <=100; i++) {
            if(i%2!=0){
                System.out.println("odd "+i);
            }
        }
    }
}